package com.seanLab.tool.TagSuggestModel;

import com.seanLab.dto.RecommendArticleDto;
import com.seanLab.dto.SuggestModelArticleDto;
import com.seanLab.dto.SuggestModelImageDto;

public class RawInfoExtractorByText extends RawInfoExtractor {
    public RawInfo extractRawInfo(SuggestModelArticleDto article, SuggestModelImageDto image, RawInfoType type) {
        RawInfoInText rawInfo = new RawInfoInText();
        switch (type) {
            case DESC_OF_IMAGE:
                rawInfo.setContent(extractDesc(image));
                break;
            case PARA_UNDER_IMAGE:
                rawInfo.setContent(extractParaUnder(article, image));
                break;
            case PARA_ABOVE_IMAGE:
                rawInfo.setContent(extractParaAbove(article, image));
                break;
            case CONTENT:
                rawInfo.setContent(extractContent(article));
                break;
            case TITLE:
                rawInfo.setContent(extractTitle(article));
                break;
            case TAG:
                rawInfo.setContent(extractTag(article));
                break;
            case SEMANTIC_OF_IMAGE:
                rawInfo.setContent(extractSemantic(article, image));
                break;
            default:
                rawInfo.setContent("");
                break;
        }
        return rawInfo;
    }

    public RawInfo extractRawInfo(RecommendArticleDto article, RawInfoType type) {
        RawInfoInText rawInfo = new RawInfoInText();
        switch (type) {
            case CONTENT:
                rawInfo.setContent(extractContent(article));
                break;
            case TITLE:
                rawInfo.setContent(extractTitle(article));
                break;
            default:
                rawInfo.setContent("");
                break;
        }
        return rawInfo;
    }

    private String extractTitle(RecommendArticleDto article) {
        String ret =  article.getTitle();
        if (ret == null) ret = "";
        return ret;
    }

    private String extractTitle(SuggestModelArticleDto article) {
        String ret =  article.getTitle();
        if (ret == null) ret = "";
        return ret;
    }

    private String extractContent(RecommendArticleDto article) {
        String ret =  article.getContent();
        if (ret == null) ret = "";
        return ret;
    }

    private String extractContent(SuggestModelArticleDto article) {
        String ret =  article.getContent();
        if (ret == null) ret = "";
        return ret;
    }

    private String extractParaAbove(SuggestModelArticleDto article, SuggestModelImageDto image) {
        String ret = image.getContextAbove();
        if (ret == null) ret = "";
        return ret;
    }

    private String extractParaUnder(SuggestModelArticleDto article, SuggestModelImageDto image) {
        String ret = image.getContextBelow();
        if (ret == null) ret = "";
        return ret;
    }

    private String extractDesc(SuggestModelImageDto image) {
        String ret = image.getDescription();
        if (ret == null) ret = "";
        return ret;
    }

    private String extractTag(SuggestModelArticleDto article) {
        //TODO 提取原有的Tag
        return "";
    }

    private String extractSemantic(SuggestModelArticleDto article, SuggestModelImageDto image) {
        //TODO 提取语义信息
        return "";
    }
}
